#region Usings

using System;
using KanbanBoard.Server.Command.DomainModel;
using KanbanBoard.Tests.Server.Utils.DSL;
using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace KanbanBoard.Tests.Server.Command.DomainModel {
    [TestClass]
    public class WhenPullingATask : DomainModelTestBase {
        [TestMethod]
        public void PlaceTaskIntoNewColumnAndRemoveFromOldColumn() {
            InitialBoard = @"
                NEW
                    UI
                WIP
                DONE";

            var column = board.Column("WIP");
            var task = board.Task("UI");

            task.Move().To(column);

            AssertBoardLooksLike(@"
                NEW
                WIP
                    UI
                DONE");
        }

        [TestMethod]
        public void CanSkipColumns() {
            InitialBoard = @"
                NEW
                    UI
                WIP
                DONE";

            var column = board.Column("DONE");
            var task = board.Task("UI");

            task.Move().To(column);

            AssertBoardLooksLike(@"
                NEW
                WIP
                DONE
                    UI");
        }

        [TestMethod, ExpectedException(typeof(InvalidOperationException))]
        public void CannotPullBackwards() {
            InitialBoard = @"
                NEW
                WIP
                    UI
                DONE";

            var column = board.Column("NEW");
            var task = board.Task("UI");

            task.Move().To(column);
        }

        [TestMethod, ExpectedException(typeof(InvalidOperationException))]
        public void CannotPullIntoTheSameColumn() {
            InitialBoard = @"
                NEW
                WIP
                    UI
                DONE";

            var column = board.Column("WIP");
            var task = board.Task("UI");

            task.Move().To(column);
        }
    }
}